package org.ims.inv.model.flow.material;

import java.util.HashSet;
import java.util.Set;

import org.ims.inv.model.flow.ModelFlowBase;

/**
 * Model: 节点材料定义
 * 
 * @author Jeccy.Zhao
 *
 */
public class ModelFlowMaterial
extends ModelFlowBase
{

	/**
	 * Serial UID
	 */
	private static final long serialVersionUID = -5965095912903372469L;
	
	/**
	 * 材料名称
	 */
	private String materialName;
	
	/**
	 * 材料描述
	 */
	private String materialDesc;
	
	/**
	 * 材料性质
	 */
	private Integer materialType;
	
	/**
	 * 父材料
	 */
	private ModelFlowMaterial materialParent;
	
	/**
	 * 子材料
	 */
	private Set<ModelFlowMaterial> materialChildren;
	
	/**
	 * Adds entity to children set
	 * @param entity
	 */
	public void addSubMaterial (ModelFlowMaterial entity)
	{
		if (materialChildren == null)
		{
			materialChildren = new HashSet<ModelFlowMaterial>();
		}
		
		boolean existed = false;
		for (ModelFlowMaterial sub : materialChildren)
		{
			if (sub.getId().equals(entity.getId()))
			{
				existed = true;
				break;
			}
		}
		
		if (!existed)
		{
			materialChildren.add(entity);
		}
	}
	
	public void setMaterialName(String materialName)
	{
		this.materialName = materialName;
	}

	public String getMaterialName()
	{
		return materialName;
	}

	public void setMaterialDesc(String materialDesc)
	{
		this.materialDesc = materialDesc;
	}

	public String getMaterialDesc()
	{
		return materialDesc;
	}

	public void setMaterialType(Integer materialType)
	{
		this.materialType = materialType;
	}

	public Integer getMaterialType()
	{
		return materialType;
	}

	public void setMaterialParent(ModelFlowMaterial materialParent)
	{
		this.materialParent = materialParent;
	}

	public ModelFlowMaterial getMaterialParent()
	{
		return materialParent;
	}

	public void setMaterialChildren(Set<ModelFlowMaterial> materialChildren)
	{
		this.materialChildren = materialChildren;
	}

	public Set<ModelFlowMaterial> getMaterialChildren()
	{
		return materialChildren;
	}
}
